<template>
  <div>
    <router-link to="/banner" style="color:black;text-decoration:none;float:left;margin-top:20px">
      <el-button type="success">
        添加
        <i class="el-icon-arrow-right"></i>
      </el-button>
    </router-link>
    <el-table
      :data="tableData"
      style="width: 100%"
      :default-sort="{prop: 'date', order: 'descending'}"
    >
      <el-table-column prop="id" label="id" sortable width="180"></el-table-column>
      <el-table-column prop="name" label="分类名" sortable width="180"></el-table-column>
      <el-table-column prop="img_url" label="图片地址"></el-table-column>
      <el-table-column fixed="right" label="操作" width="200">
        <template slot-scope="scope">
          <el-popover placement="bottom" title="标题" width="400" trigger="click">
            <el-table :data="gridData">
              <el-table-column width="150" property="date" label="日期"></el-table-column>
              <el-table-column width="100" property="name" label="姓名"></el-table-column>
              <el-table-column width="300" property="address" label="地址"></el-table-column>
            </el-table>
            <el-button slot="reference" @click="handleClick(scope.row)">编辑</el-button>
          </el-popover>
          <el-button
            type="text"
            size="small"
            @click.native.prevent="deleteRow(scope.$index, tableData)"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
export default {
  props: {},
  data() {
    return {
      tableData: [],
      gridData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        }
      ]
    };
  },

  watch: {},
  mounted() {
    this.axios({
      method: "post",
      url: "/wrd/dfl",
      params: {}
    }).then(res => {
      console.log(res);
      this.tableData = res.data.data;
      console.log(this.tableData);
    });
  },
  methods: {
    handleClick(row) {
      console.log(row);
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    }
  }
};
</script>

<style  scoped>
</style>